<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<!DOCTYPE html>
<html>
<head>
    <title>支付单详情   结款单   详情</title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <style type="text/css">
        div.group-info {
            margin-top: 10px !important;
            margin-bottom: 0px !important;
        }
        input.innerInput {
            width: 98%;
        }
    </style>
</head>
<body class="skin-blue sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>详情</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">结款单管理</a></li>
            <li class="active"><a href="#">结款单详情</a></li>
        </ol>
     </section>
     
     <section class="content" style="min-height:inherit;">
          <form id="form" class="form-horizontal"  method="post">
            <input type="hidden" name=settlementId value="${info.settlementId}" />
            
            <div class="box box-success" style="margin-bottom: 0px;padding-bottom: 10px;">
               <div class="form-group form-group-xs group-info">
                     <label for="inputTextAlter1" class="col-sm-2 text-right">结算单号：</label>
                     <div class="col-sm-4 text-left" >${info.settlementCode}</div>
                     <label for="inputTextAlter2" class="col-sm-2 text-right">结算单名称：</label>
                     <div id="orgName" class="col-sm-4 text-left">${info.settlementName}</div>
                </div>
                 
                <div class="form-group form-group-xs group-info">
                     <label for="inputTextAlter1" class="col-sm-2 text-right">总条目数：</label>
                     <div id="outstandAmt" class="col-sm-4 text-left">${info.totalOrders}</div>
                     <label for="inputTextAlter2" class="col-sm-2 text-right">总金额：</label>
                     <div id="availableAmt" class="col-sm-4 text-left">${info.totalAmount}</div>
                </div>
                
                <div class="form-group form-group-xs group-info">
                     <label for="inputTextAlter1" class="col-sm-2 text-right">创建时间：</label>
                     <div id="pendingAmt" class="col-sm-4 text-left">${info.createDatetime}</div>
                     <label for="inputTextAlter2" class="col-sm-2 text-right">创建人：</label>
                     <div id="pendingAmt" class="col-sm-4 text-left">${info.createUser}</div>
                </div> 
                <div class="form-group form-group-xs group-info">
                     <label for="inputTextAlter1" class="col-sm-2 text-right">备注：</label>
                     <div id="pendingAmt" class="col-sm-4 text-left">${info.remarks}</div>
                     <label for="inputTextAlter2" class="col-sm-2 text-right">状态：</label>
                     <div id="pendingAmt" class="col-sm-4 text-left">${info.status}</div>
                </div> 
                
            </div>
        </form>
     </section>
    
    
    <section class="content">
        <div class=" box box-primary">
            <div class="box-body">
                <div class=" form-inline">
        
                   <div class="form-group form-group-xs">
                        <label for="name">药品编码：</label>
                        <input class="form-control" type="text" id="drugName" placeholder="药品编码" maxlength="100" />
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="name">生产企业名称：</label>
                        <input class="form-control" type="text" id="compName" placeholder="生产企业名称" maxlength="200" />
                    </div>
                    
                   <button type="button" onclick="gridSerch();" class="btn btn-success btn-sm">查询</button>
                    
                </div>
            </div>
        </div>
        
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
        <div class=" box box-warning bottongroup">

            <%-- <a href="${ctx}/settlementFirst/toAddFirstDetailList.html">新 增</a> --%>
            <!-- <label id="addNew"  class="btn btn-default btn-sm">新增</label> -->
            <button type="button" onclick="removeDel();" class="btn btn-default btn-sm">删除</button>
            <!-- <button type="button" onclick="batchJoin(0)" class="btn btn-default btn-sm">提交</button> -->
            <button type="button" onclick="window.location.href='${ctx}/payment/toPaymentDetailList.html'" class="btn btn-default btn-sm">返 回</button>

        </div>
   </section> 
    
   <%@ include file="/WEB-INF/component/commonJS.jsp"%>
   <script type="text/javascript">
         $(function() {
             
             
             jQuery("#gridlist").jqGrid({
                    url: "${ctx}/settlementFirst/getSetSettlementFirstDetailDataList.html?settlementId=${param.settlementId}",
                    mtype: "POST",
                    datatype: "json",
                    autowidth: true,
                    //shrinkToFit: false,
                    height: 270,
                    colNames:[ '结算单ID','结算单明细ID','创建人','创建时间','支付明细类型','配送企业ID','配送企业','药品编码', '通用名','剂型','规格','转换系数','单位','材质','生产企业','采购价','到货数量'  ],
                    colModel:[
                        { name: 'settlementId', width:160,hidden:true,align:"center" ,sortable:false},
                        { name: 'settlementDetailId', width:160,hidden:true,align:"center" ,sortable:false},
                        { name: 'createUser', width:160,hidden:true,align:"center" ,sortable:false},  
                        { name: 'createDatetime', width:160,hidden:true,align:"center" ,sortable:false},   
                        { name: 'bankAcctTransType', width:160,align:"center" ,sortable:false},   
                        { name: 'delCompId', width:160,hidden:true,align:"center" ,sortable:false},       
                        { name: 'delCompName', width:160,align:"center" ,sortable:false},      
                        { name: 'drugCode', width:100,align:"center" ,sortable:false},
                        { name: 'drugName', width:100, align:"center",sortable:false},
                        { name: 'formName', width:80, align:"center",sortable:false},
                        { name: 'specName', width:80, align:"center",sortable:false},
                        { name: 'factor', width:80, align:"center",sortable:false},
                        { name: 'unit', width:80, align:"center",sortable:false},
                        { name: 'materialName', width:100, align:"center",sortable:false},
                        { name: 'compName', width:150, align:"center",sortable:false},
                        { name: 'proPrice', width:100, align:"center",sortable:false,
                     	   formatter:function(cellvalue, options, row){
                               return formatAmount(cellvalue, options, row);
                           }},
                        { name: 'recpCount', width:100, align:"center",sortable:false}
                        
                    ],
                     rowNum: 20,
                     rowList: [10, 20, 50, 100],
                     rownumbers: true,
                     pager: "#gridpage",
                     viewrecords: true,
                     multiselect: true, 
                     caption: "结算单详情",
                     jsonReader: {
                         repeatitems: false,
                         id: "ids"
                     }
                });
                
                $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
                
                $(window).trigger("resize");
                
            });
               
           //查询
           function gridSerch() {
               var drugName = $.trim($("#drugName").val());
               var compName = $.trim($("#compName").val());
               $("#gridlist").jqGrid('setGridParam',{  
                   datatype:'json',
                   postData:{
                       "drugName":drugName,
                       "compName":compName},
                   page:1
               }).trigger("reloadGrid"); //重新载入  
           }
         //删除
            function removeDel(){
                var rowIds = $("#gridlist").jqGrid("getGridParam", "selarrrow") || [];
                if (rowIds.length <= 0) {
                    $.HN.message.alert("请选择要刪除的结算单！", "消息", "error");
                    return;
                }
                var list = [];
                for (var i=0; i<rowIds.length; i++) {
                    rowId = rowIds[i];
                    var rowdata = $("#gridlist").jqGrid('getRowData', rowId);
                    list.push({"settlementDetailId":rowdata.settlementDetailId});
                }
                $.post("${ctx}/settlementFirst/deleteSetSettlementFirstDetail.html?settlementDetailId=${param.settlementDetailId}", {
                    "array" : json.jsonToString(list)
                    }, function(result) {
                        if (result.success) {
                            $.HN.message.alert("刪除成功！", "消息", "success");
                            gridSerch();
                        } else {
                            $.HN.message.alert("操作失败！", "消息", "error");
                        }
                    }, "json")
            }
            
    </script>
</body>
</html>